Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ref: Simplify expressions in physical plan #782

Merged
merged 7 commits into from
Oct 2, 2023

Conversation

bjchambers
Copy link
Collaborator

Change expressions to always produce the result of the expression. This simplifies evaluation, without affecting the expressiviness:

  1. We can now produce a primitive result (such as a boolean or integer) if that is the type of the final expression.
  2. We can still produce records by adding a record expression to the end (which is the standard way of creating intermediate records).
  3. We can still reference parts of a record input using FieldRef.

This eliminates the weird "some expressions are marked as output" pattern. It also means that we can operate on ArrayRef generally and use DataType as the type, instead of sometimes using RecordBatch and SchemaRef.

Other smaller changes in this PR:

  • Move the Expressions out of the StepKind. This allows the StepKind to serve as an identifier of the step, regardless of the expressions it computes, simplifying some of the de-duplication work in the logical-to-physical compilation.
  • Rename the column expression to input, since it accesses the input data to the expression evaluation.
  • Addition of a method to "intern" expression names, replacing a &str with &'static str for expression operators available in the binary.

Change expressions to always produce the result of the expression.
This simplifies evaluation, without affecting the expressiviness:

1. We can now produce a primitive result (such as a boolean or integer)
   if that is the type of the final expression.
2. We can still produce records by adding a `record` expression to the
   end (which is the standard way of creating intermediate records).
3. We can still reference parts of a record input using `FieldRef`.

This eliminates the weird "some expressions are marked as output"
pattern. It also means that we can operate on `ArrayRef` generally and
use `DataType` as the type, instead of sometimes using `RecordBatch` and
`SchemaRef`.

Other smaller changes in this PR:
- Move the `Expressions` out of the `StepKind`. This allows the
  `StepKind` to serve as an identifier of the step, regardless of the
  expressions it computes, simplifying some of the de-duplication work
  in the logical-to-physical compilation.
- Rename the `column` expression to `input`, since it accesses the
  input data to the expression evaluation.
- Addition of a method to "intern" expression names, replacing a `&str`
  with `&'static str` for expression operators available in the binary.
@cla-bot cla-bot bot added the cla-signed Set when all authors of a PR have signed our CLA label Sep 29, 2023
Copy link
Collaborator

@jordanrfrazier jordanrfrazier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, good simplification of expressions

crates/sparrow-expressions/src/evaluators.rs Outdated Show resolved Hide resolved
crates/sparrow-logical/src/expr.rs Show resolved Hide resolved
crates/sparrow-physical/src/step.rs Outdated Show resolved Hide resolved
@bjchambers bjchambers added this pull request to the merge queue Oct 2, 2023
Merged via the queue into main with commit 0e4bc08 Oct 2, 2023
32 checks passed
@bjchambers bjchambers deleted the ben/updates-to-logical-plans branch October 2, 2023 18:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed Set when all authors of a PR have signed our CLA refactor sparrow
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants